//
// Created by lz on 3/1/21.
//

#ifndef _POLLPOLLER_H_
#define _POLLPOLLER_H_

#include "net/Poller.h"
#include <vector>

struct pollfd;

namespace lzweb
{
	namespace net
	{
		///
		/// IO Multiplexing with poll(2).
		///
		class PollPoller : public Poller
		{
		 public:
			PollPoller(EventLoop* loop);
			~PollPoller() override;

			TimeStamp poll(int timeoutMs, ChannelList* activeChannels) override;

			void updateChannel(Channel* channel) override;
			void removeChannel(Channel* channel) override;

		 private:
			void fillActiveChannels(int numEvents,
				ChannelList* activeChannels) const;

		 	using PollFdList = std::vector<struct pollfd>;

		 	PollFdList  pollfds_;

		};

	}// namespace net
}// namespace lzweb



#endif //_POLLPOLLER_H_
